package com.rocket.producer.controller;

import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.nio.charset.StandardCharsets;


@RestController
public class Producer {
    @Resource
    private RocketMQTemplate rocketMQTemplate;


    @RequestMapping("/push")
    public String get() {
        rocketMQTemplate.convertAndSend("mytopic", "helloWorld!" );
        return "生产者";
    }
    @RequestMapping("/newUser")
    public String userReg() {
        String user01 = "name: lwb, id:01, password: 111";
        rocketMQTemplate.convertAndSend("user1", user01 );
        return "用户注册";
    }

}
